#!/usr/bin/env python3
# -*- coding: utf-8 -*-

sorted([2, -2, 1, 6, 4])

sorted([2, -2, 1, 6, 4], key = abs)

sorted(['bob', 'about', 'Zoo', 'Credit'], key = str.lower, reverse = True)


L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]
#sorted 按名字排序
def by_name(t):
    return t[0]

L2 = sorted(L, key = by_name)
print(L2)

#sorted 按成绩排序
def by_score(t):
    return -t[1]

L3 = sorted(L, key = by_score)
print(L3)